from pathlib import Path

file = Path("D:\dev\PythonProject\python_learning\chapter10.2\programming.txt")

contents = "I love programming.\n"
contents += "I love creating new games.\n"
contents += "I also love working with data.\n"
file.write_text(contents)